package code.tools.behavior.achieve
{
	import code.main.App;
	import code.main.AppData;
	import code.tools.behavior.IAppear;
	
	import com.greensock.TweenLite;
	import com.greensock.easing.Back;
	
	import flash.display.Sprite;
	import flash.events.Event;

	/**
	 *面板从屏幕上方移到屏幕正中央
	 * @author liangqian
	 * 
	 */	
	public class AppaerMove implements IAppear
	{
		/**
		* 面板引用
		*/
		private var _mPanel:Sprite;
		/**
		 * 面板出现后执行的操作
		 */
		private var _callBack:Function;
		public function AppaerMove(_mPanel:Sprite, callback:Function = null)
		{
			this._mPanel = _mPanel;
			this._callBack = callback;
			_mPanel.visible = false;
		}
		
		public function appear():void
		{
			TweenLite.killTweensOf(_mPanel);
			_mPanel.x = -App.appstage.stageWidth*.5;
			_mPanel.visible = true;
			TweenLite.to(_mPanel, 0.5, { x:_mPanel.parent.width/2,ease:Back.easeInOut} );
		}
		private function completeHandler():void
		{
			_mPanel.mouseEnabled = _mPanel.mouseChildren = true;
			if (_callBack != null){
				_callBack();
			}
		}
	}
}